<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Data_customer extends Authenticated{
	
	function __construct() {
		parent::__construct();
		$this->load->model("data_customer_model");
                $this->load->model("fungsi_model");
	}
	
	function index(){
		$this->list_data_customer() ;
	}
	
        function list_data_customer()
        {
            $data['list_data_customer']=$this->data_customer_model->get_all_data_customer();
            $this->load->view('header');
            $this->load->view('data_customer/list_data_customer',$data);
            $this->load->view('footer');
        }
        
        function get_data_customer()
        {
            $data_temp=  $this->input->post('data_customer');
            //echo $data_temp;
            $temp = explode("\"",$data_temp);
            $data['id'] = $temp[3];
            $filter_result = $this->data_customer_model->get_data_customer($data['id']);
            echo json_encode($filter_result);
        }
        
        function get_data_customer_lengkap()
        {
            $data_temp=  $this->input->post('data_customer');
            //echo $data_temp;
            $temp = explode("\"",$data_temp);
            $data['id'] = $temp[3];
            $filter_result = $this->data_customer_model->get_data_customer($data['id']);
            echo json_encode($filter_result);
        }
        
        function get_data_customer_autocomplete()
        {
            $data['no_pengenal']=  $this->input->post('no_pengenal');
            $data['jenis_pengenal']=  $this->input->post('jenis_pengenal');
            $filter_result = $this->data_customer_model->get_data_customer_clause($data);
            echo json_encode($filter_result);
        }
        
        function add_data_customer()
        {
            $this->load->view('header');
            $this->load->view('data_customer/add_data_customer');
            $this->load->view('footer');
        }
        
        function add_data_customer_process()
        {
            $data = $_GET;
            $this->data_customer_model->add_data_customer($data);
            redirect(DATACUSTOMER);
        }
        
        function edit_data_customer($id)
        {
            $data = $this->data_customer_model->get_data_customer($id);
            $this->load->view('header');
            $this->load->view('data_customer/form_edit_data_customer',$data);
            $this->load->view('footer');
        }
        
        function edit_data_customer_process()
        {
            $data = $_GET;
            $this->data_customer_model->update_data_customer($data);
            redirect(DATACUSTOMER);
        }
        
        function delete_data_customer($id)
        {
            $this->data_customer_model->delete_data_customer($id);
            redirect(DATACUSTOMER);
        }
	
}
/** End of file */
